// 新闻相关的接口
import myaxios from '@/utils/request.js'

// 获取标题获取新闻的数据
function articlesGet (id) {
  return myaxios({
    url: '/app/v1_1/articles',
    method: 'GET',
    needToken: true,
    params: {
      channel_id: id,
      timestamp: Date.now(),
      with_top: 1
    }
  })
}

// 对文章不感兴趣
function dislikearticle (artid) {
  return myaxios({
    url: '/app/v1_0/article/dislikes',
    method: 'post',
    needToken: true,
    data: {
      target: artid
    }
  })
}

// 举报文章
function reporArticle (artid, type, remark) {
  return myaxios({
    url: '/app/v1_0/article/reports',
    method: 'POST',
    needToken: true,
    data: {
      target: artid,
      type: type,
      remark: remark
    }
  })
}

// 拉黑作者
function blacklist (autid) {
  return myaxios({
    url: '/app/v1_0/user/blacklists',
    method: 'post',
    needToken: true,
    data: {
      target: autid
    }
  })
}

// 获取文章详情
function getArticleDet (artid) {
  return myaxios({
    url: `/app/v1_0/articles/${artid}`,
    method: 'get',
    needToken: true
  })
}

// 关注作者
function apiFollow (autid) {
  return myaxios({
    url: '/app/v1_0/user/followings',
    method: 'post',
    needToken: true,
    data: {
      target: autid
    }
  })
}

// 取关作者
function apiDisFollow (autid) {
  return myaxios({
    url: `/app/v1_0/user/followings/${autid}`,
    method: 'DELETE',
    needToken: true
  })
}

// 给文章点赞
function apiLike (artid) {
  return myaxios({
    url: '/app/v1_0/article/likings',
    method: 'post',
    needToken: true,
    data: { target: artid }
  })
}

// 取消给文章点赞
function apiDisLike (artid) {
  return myaxios({
    url: `/app/v1_0/article/likings/${artid}`,
    method: 'DELETE',
    needToken: true
  })
}

// 不喜欢文章
function apiDistaste (artid) {
  return myaxios({
    url: '/app/v1_0/article/dislikes',
    method: 'post',
    needToken: true,
    data: { target: artid }
  })
}

// 取消不喜欢
function apiTaste (artid) {
  return myaxios({
    url: `/app/v1_0/article/dislikes/${artid}`,
    method: 'DELETE',
    needToken: true
  })
}

export {
  articlesGet,
  dislikearticle,
  reporArticle,
  blacklist,
  getArticleDet,
  apiFollow,
  apiDisFollow,
  apiLike,
  apiDisLike,
  apiDistaste,
  apiTaste
}
